<template>
 <div class="page">
     <div class="header">
          <div class="name">
              监控名称
          </div>
          <div class="status">
              <a-button class="monitor" type="primary" @click="showFn" :loading="loading" :disabled="loading">{{ show ? '隐藏' : '显示' }}</a-button>
          </div>
      </div>
     <div class="main">
        <div class="item" v-for="(item, index) in datas" :key="index">
            <div class="name" :title="item[field]">
                {{ item[field] }}
            </div>
            <div class="status" @click="position(item)">
                {{ btnText }}
            </div>
        </div>
         <zlc-nodata v-if="!datas || !datas.length"></zlc-nodata>
     </div>
 </div>
</template>

<script>
import {onMounted, reactive, ref} from "vue";
import zlcNodata from "../../../components/zlcNodata/zlcNodata.vue";
export default {
    name: "evaluationStatistics",
    components: {
        zlcNodata

    },
    props:{
      datas:{
          type: Array,
          default(){
              return []
          }
      },
        field:{
          type:String,
            default(){
              return 'monitorName'
            }
        },
        btnText:{
          type: String,
            default(){
              return '定位'
            }
        }
    },
    setup(props, ctx){
        let loading = ref(false)
        let show = ref(false)
      let showFn = () => {
          ctx.emit('change')
          show.value = !show.value

          if(!show.value) return
          loading.value = true
      }
      let position = (item) => {
            ctx.emit('position', item.longitude, item.latitude)
      }
      onMounted(() => {

      })
     return {
         showFn,
         loading,
         show,
         position
     }
    }
}
</script>

<style scoped lang="less">
.page {
  width: 100%;
  height: 100%;
  color: #fff;
  padding: 10px 0;
  box-sizing: border-box;

  .header{
    width: 100%;
    height: 40px;
    line-height: 40px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    background: url("/src/assets/titlebcg.png") center center no-repeat;
    background-size: 100% 100%;
    padding: 0 10px 0 20px;
    box-sizing: border-box;
    .status{
      .monitor{
        height: 30px;
      }
      //&:deep(){
      //
      //
      //}
      /*覆盖ant-design-vue 样式**/
      .ant-btn-primary[disabled],.ant-btn-primary[disabled]:hover {
        color: #ffffff !important;
      }
    }
  }
  .main{
    width: 100%;
    height: calc(100% - 40px);
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.05);

    /* 滚动条优化 start */
    &::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    /* 无内容时的滚动条样式 */
    &::-webkit-scrollbar-track {
      -webkit-box-shadow: inset 0 0 5px rgb(64, 128, 230);
      border-radius: 4px;
      background: rgba(117, 207, 239, 0.1);
    }

    /* 有内容时的滚动条样式 */
    &::-webkit-scrollbar-thumb {
      background: rgb(9, 108, 222);
      border-radius: 4px;
    }

    &::-webkit-scrollbar-thumb:hover {
      background: rgba(72, 136, 234, 0.8);
    }

    &::-webkit-scrollbar-corner {
      background: rgba(0, 0, 0, 0.1);
    }

    /* 滚动条优化 end */
    .item{
      width: 100%;
      height: 50px;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      padding: 0 20px;
      box-sizing: border-box;
      border-bottom: 1px solid #4579c7;
      font-size: 16px;
      .name{
        width: calc(100% - 64px);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .status{
        height: fit-content;
        padding: 2px 4px;
        background: rgba(0, 160, 255, .5);
        border-radius: 4px;
        font-size: 14px;
        cursor: pointer;
      }
    }
  }
}
</style>
